package com.renke.server;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * @Description
 * @Auther Z.R.K
 * @Date 2020/12/7 14:51
 **/
@Slf4j
public class BaseThread implements Runnable{
    Socket socket ;

    public void setSocket(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream in = socket.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            while(true){
                log.info("readLine {}", reader.readLine());
                log.info("socket isClosed {}", socket.isClosed());
                log.info("socket isConnected {}", socket.isConnected());
                log.info("socket isInputShutdown {}", socket.isInputShutdown());
                log.info("socket isOutputShutdown {}", socket.isOutputShutdown());
                if(socket.isClosed() || !socket.isConnected()){
                    return ;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
